<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>父子组件</title>
  </head>
  <body>
    <div id="app">
      <my-root></my-root>
    </div>

    <template id="root">
      <div style="width: 100%; height: 500px; background-color: aqua">
        <input type="color" v-model="color" />
        <my-box></my-box>
      </div>
    </template>

    <template id="box">
      <div
        :style="{width:'300px',height: '300px','background-color': bgColor}"
      ></div>
    </template>
    <script src="../lib/vue.global.js"></script>
    <script>
      const Box = {
        template: "#box",
        data() {
          return {
            bgColor: "#ccc",
          };
        },
      };
      const Root = {
        template: "#root",
        components: {
          MyBox: Box,
        },
        data() {
          return {
            color: "#f66",
          };
        },
      };

      const app = Vue.createApp({
        components: {
          MyRoot: Root,
        },
      });
      app.mount("#app");
    </script>
  </body>
</html>
